<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/template.xhtml">
	<ui:define name="head">
	</ui:define>
	<ui:define name="content">
		<div id="head" align="center">
			<h:outputText value="#{label.createUser}" style="font-size: 30px;" />
			<hr></hr>
		</div>
		<h:form id="createUser">
			<br />
			<h:panelGrid columns="3" style=" height : 70px;">

				<h:outputText value="#{label.role}" />
				<h:selectOneMenu id="role" disabled="#{userAction.readonly}"
					value="#{userAction.targetEntity.role}">
					<f:selectItems value="#{userAction.roleValues}" />
				</h:selectOneMenu>
				<h:message for="role" errorStyle="color: red;"
					styleClass="errorMessage" />

				<h:outputText value="#{label.name}" />
				<h:inputText id="name" disabled="#{userAction.readonly}"
					value="#{userAction.targetEntity.name}" required="true"
					requiredMessage="#{message['javax.faces.component.UIInput.REQUIRED']}"
					validatorMessage="#{message['javax.faces.validator.LengthValidator.MINIMUM']}">
					<f:validateLength for="name" minimum="2" maximum="25" />
				</h:inputText>
				<rich:message for="name" errorStyle="color: red;"
					styleClass="errorMessage" />

				<h:outputText value="#{label.middleName}" />
				<h:inputText id="middlename" disabled="#{userAction.readonly}"
					value="#{userAction.targetEntity.middleName}" required="true"
					requiredMessage="#{message['javax.faces.component.UIInput.REQUIRED']}"
					validatorMessage="#{message['javax.faces.validator.LengthValidator.MINIMUM']}">
					<f:validateLength for="middlename" minimum="2" maximum="25" />
				</h:inputText>
				<rich:message for="middlename" errorStyle="color: red;"
					styleClass="errorMessage" />

				<h:outputText value="#{label.lastName}" />
				<h:inputText id="lastname" disabled="#{userAction.readonly}"
					value="#{userAction.targetEntity.lastName}" required="true"
					requiredMessage="#{message['javax.faces.component.UIInput.REQUIRED']}"
					validatorMessage="#{message['javax.faces.validator.LengthValidator.MINIMUM']}">
					<f:validateLength for="lastname" minimum="2" maximum="25" />
				</h:inputText>
				<rich:message for="lastname" errorStyle="color: red;"
					styleClass="error" />

				<h:outputText value="#{label.email}" />
				<h:inputText id="email" disabled="#{userAction.readonly}"
					value="#{userAction.targetEntity.email}" required="true"
					requiredMessage="#{message['javax.faces.component.UIInput.REQUIRED']}">
					<f:validator for="email" validatorId="existingUserEmailValidator" />
				</h:inputText>
				<rich:message for="email" errorStyle="color: red;"
					styleClass="errorMessage" />

				<h:commandButton rendered="#{not userAction.readonly}"
					action="#{userAction.save}" value="#{label.save}"
					styleClass="saveButton" />

				<h:commandButton rendered="#{not userAction.readonly}"
					immediate="true" action="#{userAction.actionCancel}"
					value="#{label.cancel}" />

				<rich:message for="createUser" infoStyle="color: green;"
					errorStyle="color: red;" styleClass="errorMessage" />
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
</html>
